package com.mytrip.base.service;

import java.io.Serializable;
import java.util.List;

import com.mytrip.base.model.BaseModel;

/**
 * BaseManager Manager that talks to BaseDao to CRUD POJOs.
 * 
 * <p>
 * Extend this interface if you want typesafe (no casting necessary) managers
 * for your domain objects.
 * 
 * @author evan
 * @version 0.1, 2008-3-9
 * @since   JDK1.6
 */
public interface GenericManager<T extends BaseModel, PK extends Serializable> extends BaseManager{

	/**
	 * Generic method used to getSku all objects of a particular type. This is the
	 * same as lookup up all rows in a table.
	 * 
	 * @return List of populated objects
	 */
	public List<T> getAll();

	/**
	 * Generic method to getSku an object based on class and identifier. An
	 * ObjectRetrievalFailureException Runtime Exception is thrown if nothing is
	 * found.
	 * 
	 * @param id
	 *            the identifier (primary key) of the object to getSku
	 * @return a populated object
	 * @see org.springframework.orm.ObjectRetrievalFailureException
	 */
	public T get(PK id);

	/**
	 * Checks for existence of an object of type T using the id arg.
	 * 
	 * @param id
	 * @return - true if it existSku, false if it doesn't
	 */
	public boolean exists(PK id);

	/**
	 * Generic method to saveSku an object - handles both update and insert.
	 * 
	 * @param object
	 *            the object to saveSku
	 */
	public T save(T object);

	/**
	 * Generic method to deleteSku an object based on class and id
	 * 
	 * @param id
	 *            the identifier (primary key) of the object to removeSku
	 */
	public void remove(PK id);
}
